//
//  NSDictionary+ToArray.m
//  LoveExpressBusiness
//
//  Created by 刘甲奇 on 2017/5/16.
//  Copyright © 2017年 DFH. All rights reserved.
//

#import "NSDictionary+ToArray.h"

@implementation NSDictionary (ToArray)
- (NSMutableArray *)toArray:(NSDictionary *)dict
{
    NSMutableArray *tempArray = [NSMutableArray array];

    for (NSString *key in dict.allKeys) {
        id obj = dict[key];
        [tempArray addObject:obj];
    }
    return tempArray;
}
- (NSMutableArray *)toLineDataArray:(NSDictionary *)dict
{
    NSMutableArray *tempArray = [NSMutableArray array];
    
    for (NSString *key in dict.allKeys) {
        id obj = dict[key];
        if ([obj isKindOfClass:[NSNull class]]) {
            NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
            [dictionary setObject:@"0" forKey:@"salesum"];
            [dictionary setObject:@"0" forKey:@"allnum"];
            [dictionary setObject:@"0" forKey:@"dayval"];
            [dictionary setObject:@"0" forKey:@"addtime"];
            [tempArray addObject:dictionary];

        }else{
            [tempArray addObject:obj];
        }

    }
    return tempArray;
}
+ (NSMutableArray *)descend:(NSMutableArray *)originalArray
{
    [originalArray sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2)
     {
         
         if ([obj1 integerValue] < [obj2 integerValue])
         {
             return NSOrderedDescending;
         }
         else
         {
             return NSOrderedAscending;
         }
     }];
    return originalArray;
}


@end


